#@head() #@header()
<title>客户列表</title>
#@aside("user")
<script type="text/javascript" src="#(path)/assets/js/jquery.tmpl.min.js"></script>
<style>
	.box-body{padding:5px !important}
</style>
<div class="content-wrapper">
	<section class="content">
	<div class="nav-tabs-custom">
	#@usersmenu("repaymentlist")
            <div class="tab-content">
              <div class="tab-pane active" id="tab_1">
				<label style="float:left;margin-top:17px;margin-left:20px;">还款时间:</label>
				<input type="text" id="startime" class="form-control" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" style="width:120px;float:left;margin-top:10px;margin-left:10px;">
				<span style="float:left;margin:15px 5px 0 5px;">—</span>
				<input type="text" id="endtime" class="form-control" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" style="width:120px;float:left;margin-top:10px;margin-right:20px;">
				<div class="input-group margin" style="float:left">
					<label style="float:left;margin-top:5px;margin-left:20px;">标的名称:</label>
					<input id="bidname" style="margin-left:20px;float:left;width:150px" type="text" placeholder="" class="form-control"  >
					<label style="float:left;margin-top:5px;margin-left:20px;">用户名:</label>
					<input id="mobile" style="margin-left:20px;float:left;width:150px" type="text" placeholder="" class="form-control"  >
					<label style="float:left;margin-top:5px;margin-left:20px;">真实姓名:</label>
					<input id="realname1" style="margin-left:20px;float:left;width:150px" type="text" placeholder="" class="form-control"  >
					<label style="float:left;margin-top:8px;margin-left:5px;">状态：</label>
					<select id="status" style="width:120px;float:left" class="form-control">
						<option value="">全部</option>
						<option value="process">还款中</option>
						<option value="success">已还款</option>
					</select> 
					<span style="float:left;margin-left:20px;" class="input-group-btn">
					  <button id="bidseach" type="button" class="btn btn-info btn-flat">搜索</button>
					</span>
				</div>
				<table class="table table-bordered" style="margin-top:20px;clear:both;max-width:1000px;margin-left:10px;">
					<tbody>
					<tr>
					  <th>还款金额：<span id="total"></span> （本金：<span id="total_amount"></span> 利息：<span id="total_interest"></span>  额外加息：<span id="total_plus"></span> 优惠券：<span id="total_jxq"></span> ）</th>
					  <th>还款笔数：<span id="count"></span></th>
					</tr>
					<tr>
					  <th>待还款金额：<span id="pay"></span> （本金：<span id="pay_amount"></span> 利息：<span id="pay_interest"></span>  额外加息：<span id="pay_plus"></span> 优惠券：<span id="pay_jxq"></span> ）</th>
					  <th>待还款笔数：<span id="pay_count"></span></th>
					</tr>
				  </tbody>
			    </table>
				<div class="box-body">
					<table id="example1" class="table table-striped">
						<thead>
							<tr>
								<th>用户名</th>
								<th>真实姓名</th>
								<th>标的名称</th>
								<th>还款机构</th>
								<th>还款时间</th>
								<th>还款方式</th>
								<th>本金(元)</th>
								<th>利息(元)</th>
								<th>额外加息(元)</th>
								<th>优惠券(元)</th>
								<th>总金额(元)</th>
								<th>状态</th>	

							</tr>
						</thead>
						<tbody id="shenheall">

						</tbody>
					</table>
				</div>
				<div class="box-footer clearfix">
				  <ul class="pagination pagination-sm no-margin pull-right">
					<li id = "shall1"><a href="#">首页</a></li>
					<li id = "shall2"><a href="#">上一页</a></li>
					<li><a href="#">第<span id="shall5"></span>页 共<span id="shall6"></span>页</a></li>
					<li id = "shall3"><a href="#">下一页</a></li>
					<li id = "shall4"><a href="#">尾页</a></li>
				  </ul>
				</div>
              </div>
            <!-- /.tab-content -->
          </div>
	</section>
</div>
#@footer()
 <script id="shenhejieguo" type="text/x-jquery-tmpl">
	<tr>
		<td>${mobile}</td>
		<td>${realname}</td>
		<td>${bid_name}</td>
		<td>${repay_user_name}</td>
		<td>${repay_time}</td>
		<td>${itemtype}</td>
		<td>￥${amount}</td>
		<td>￥${interest}</td>
		<td>￥${plus}</td>
		<td>￥${jxq}</td>
		<td>￥${amounts}</td>
		<td><span class="badge ${cla}">${aa}</span></td>
	</tr>
</script>
<script>
function shall(pageNumber,startime,endtime,bidname,realname1,mobile,status){	
	if(!$.isBlank(bidname)){
		bidname = '~'+bidname;
	}
	var url = "/repay/list?token=#(session.token??)&page="+pageNumber+"&size=14&status="+status+"&repayTimeStart="+startime+"&repayTimeEnd="+endtime+"&bidName="+bidname+"&mobile="+mobile+"&realName="+realname1;
	$.getJSON(url, function(shlist) {
		 console.log(shlist);
		 $("#count").html(shlist.data.count +"笔 ");  
		$("#pay").html(shlist.data.pay +"元 ");
		$("#pay_amount").html(shlist.data.pay_amount +"元 ");
		$("#pay_count").html(shlist.data.pay_count +"笔 ");
		$("#pay_interest").html(shlist.data.pay_interest+"元 ");
		$("#pay_jxq").html(shlist.data.pay_jxq+"元 ");
		$("#pay_plus").html(shlist.data.pay_plus+"元 ");
		$("#total").html(shlist.data.total+"元 ");
		$("#total_amount").html(shlist.data.total_amount+"元 ");
		$("#total_interest").html(shlist.data.total_interest+"元 ");
		$("#total_jxq").html(shlist.data.total_jxq+"元 ");
		$("#total_plus").html(shlist.data.total_plus+"元 ");
		totalPage = shlist.data.page.totalPage;
		$("#shall6").html(totalPage);
		$.each(shlist.data.page.list, function(i, item){ 
			var aa=item.status;
			var cla="";
			if(aa=="process")
			{aa="还款中";cla="bg-yellow"}
			else if(aa=="success")
			{aa="已还款";cla="bg-green"}
			if(item.type=="capital"){var itemtype="按月等额本金"}else if(item.type=="interest"){var itemtype="按月等额本息"}
			else if(item.type=="all"){var itemtype="到期归还本金及利息"}else if(item.type=="all"){var itemtype="按月还息，到期还本"}
			var amounts = (item.amount + item.interest + item.jxq+item.plus).toFixed(2);
			var jieguolist = {mobile:item.mobile,realname:item.real_name,plus:item.plus,jxq:item.jxq,interest:item.interest,bid_name:item.bid_name,actual_repay_time:item.actual_repay_time,repay_time:item.repay_time,amount:item.amount,aa:aa,cla:cla,id:item.id,itemtype:itemtype,interest:item.interest,amounts:amounts,repay_user_name:item.repay_real_name};
			$("#shenhejieguo").tmpl(jieguolist).appendTo('#shenheall');
			
		});
	});
}
var startime = "";
var endtime ="";
var bidname = "";
var realname1='';
var mobile='';
var status = "process*success";
 $(document).ready(function(){ 
	$("#shenheall").empty();
	pageNumber = 1;
	shall(pageNumber,startime,endtime,bidname,realname1,mobile,status);
	$("#shall5").html(pageNumber);
});
$("#shall1").click(function(){
	$("#shenheall").empty();
	pageNumber = 1;
	shall(pageNumber,startime,endtime,bidname,realname1,mobile,status);
	$("#shall5").html(pageNumber);
});
$("#shall2").click(function(){
	if(pageNumber==1){
		alert("当前页是首页!");
	}else{
		$("#shenheall").empty();
		pageNumber = pageNumber-1;
		shall(pageNumber,startime,endtime,bidname,realname1,mobile,status);
		$("#shall5").html(pageNumber);
	}
});
$("#shall3").click(function(){
	if(pageNumber==totalPage){
		alert("当前页是尾页!");
	}else{
		$("#shenheall").empty();
		pageNumber = pageNumber +1;
		shall(pageNumber,startime,endtime,bidname,realname1,mobile,status);
		$("#shall5").html(pageNumber);
	}
});
$("#shall4").click(function(){
	$("#shenheall").empty();
	pageNumber = totalPage;
	shall(pageNumber,startime,endtime,bidname,realname1,mobile,status);
	$("#shall5").html(pageNumber);
});
$("#bidseach").click(function(){
	$("#shenheall").empty();
	if($("#startime").val()==""){
		startime="";
	}else{
		startime = $("#startime").val()+" 00:00:00";
		console.log(startime);
	}
	if($("#endtime").val()==""){
		endtime="";
	}else{
		endtime = $("#endtime").val()+" 23:59:59";
	}
	pageNumber = 1;
	realname1 = $("#realname1").val();
	mobile = $("#mobile").val();
	bidname = $("#bidname").val();
	status = $("#status").val();
	shall(pageNumber,startime,endtime,bidname,realname1,mobile,status);
	$("#shall5").html(pageNumber);
});
</script> 

</body>
</html>

